{__NOLAYOUT__}
<link rel="stylesheet" href="assets/store/css/amazeui.min.css"/>
<link rel="stylesheet" href="assets/store/css/app.css"/>
<link rel="stylesheet" href="//at.alicdn.com/t/font_783249_t6knt0guzo.css">
<script src="assets/store/js/jquery.min.js"></script>
<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-cf">代理列表</div>
                </div>

                <div class="page_toolbar am-margin-bottom-xs am-cf">
                    <form class="toolbar-form" method="get" action="">
                        <input type="hidden" name="s" value="<?=$url?>">
                        <div class="am-u-sm-12">
                            <div class="am fr">
                                <div class="am-form-group am-fl">
                                    <div class="am-input-group am-input-group-sm tpl-form-border-form">
                                        <input type="text" class="am-form-field" name="keyword" placeholder="请输入手机号、昵称进行搜索" value="<?=$keyword?>">
                                        <div class="am-input-group-btn">
                                            <button class="am-btn am-btn-default am-icon-search" type="submit"></button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>

                <div class="widget-body am-fr">
                    <div class="am-scrollable-horizontal am-u-sm-12">
                        <table width="100%" class="am-table am-table-compact am-table-striped
                         tpl-table-black am-text-nowrap">
                            <thead>
                            <tr>
                                <th>用户ID</th>
                                <th>微信头像</th>
                                <th>微信昵称</th>
                                <th>代理级别</th>
                                <th>手机号</th>
                                <th>性别</th>
                                <th>国家</th>
                                <th>省份</th>
                                <th>城市</th>
                                <th>注册时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php if (!$list->isEmpty()): foreach ($list as $item): ?>
                                <tr id="row-<?= $item['user_id'] ?>">
                                    <td class="am-text-middle"><?= $item['user_id'] ?></td>
                                    <td class="am-text-middle">
                                        <a href="<?= $item['avatarUrl'] ?>" title="点击查看大图" target="_blank">
                                            <img src="<?= $item['avatarUrl'] ?>" width="72" height="72" alt="">
                                        </a>
                                    </td>
                                    <td class="am-text-middle"
                                        id="nickName-<?= $item['user_id'] ?>"><?= $item['nickName'] ?></td>
                                    <td class="am-text-middle"
                                        id="agentName-<?= $item['user_id'] ?>"><?= $item['agentName'] ?></td>
                                    <td class="am-text-middle"
                                        id="mobile-<?= $item['user_id'] ?>"><?= $item['mobile'] ?></td>
                                    <td class="am-text-middle"><?= $item['gender'] ?></td>
                                    <td class="am-text-middle"><?= $item['country'] ?: '--' ?></td>
                                    <td class="am-text-middle"><?= $item['province'] ?: '--' ?></td>
                                    <td class="am-text-middle"><?= $item['city'] ?: '--' ?></td>
                                    <td class="am-text-middle"><?= $item['create_time'] ?></td>
                                    <td class="am-text-middle">
                                        <a href="javascript:void(0)" onclick="selectAgent(<?= $item['user_id'] ?>)"
                                           class="am-btn-sm am-btn am-btn-default am-btn-success am-radius">
                                            选择
                                        </a>
                                    </td>
                                </tr>
                            <?php endforeach; else: ?>
                                <tr>
                                    <td colspan="8" class="am-text-center">暂无记录</td>
                                </tr>
                            <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">
                        <div class="am-fr"><?= $list->render() ?> </div>
                        <div class="am-fr pagination-total am-margin-right">
                            <div class="am-vertical-align-middle">总记录：<?= $list->total() ?></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>

    function selectAgent(userId) {
        var nickName = $('#nickName-' + userId).html();
        var agentName = $('#agentName-' + userId).html();
        var mobile = $('#mobile-' + userId).html();
        var agent = {user_id: userId, nick_name: nickName, agent_name: agentName, mobile: mobile};
        console.log(nickName);
        parent.document.getElementById("upperName").innerText = nickName;
        parent.document.getElementById("upper-id").value = userId;
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    }
</script>

